home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
howtos1r
/
module1.bas
< prev
next >
Wrap
BASIC Source File
|
1999-08-11
|
3KB
|
96 lines
Attribute VB_Name = "Module1"
Global MemLoad(32767) As Integer
Global Phys(32767) As Integer
Global Virt(32767) As Integer
Global OldPos As Integer
Global Currpos As Integer
Global MemPC As Integer
Global PhysPC As Integer
Global VirtPC As Integer
Global FileToBeLoaded As String
Sub LOAD(Filename As String)
'****LOADING****
'Loading the whole file as a string and then dividing it out again
'goes a lot quiker than load everything in using "Line Input" method
' especially when you have the potential of 98301 figures
Dim IntD1 As Integer, IntD2 As Integer
Open Filename For Input As #2
Input #2, FileToBeLoaded 'Gets Whole File as 1 String
Close #2
ProcessIT
End Sub
Sub ProcessIT()
Dim BugLine As String
IntD1 = InStr(1, FileToBeLoaded, Chr$(13))
IntD2 = InStr(IntD1 + 1, FileToBeLoaded, Chr$(13))
BugLine = Mid$(FileToBeLoaded, IntD1, IntD2 - IntD1) 'The First Line is always Cocked Up
IntD1 = IntD2 + 1
IntD2 = InStr(IntD1, FileToBeLoaded, Chr$(13))
Currpos = Mid$(FileToBeLoaded, IntD1, IntD2 - IntD1) 'Note: the string we want goes here
'Load DATA in to the arrays
For i = 0 To Currpos
IntD1 = IntD2 + 1
IntD2 = InStr(IntD1, FileToBeLoaded, Chr$(13))
MemLoad(i) = Val(Mid$(FileToBeLoaded, IntD1, IntD2 - IntD1))
IntD1 = IntD2 + 1
IntD2 = InStr(IntD1, FileToBeLoaded, Chr$(13))
Phys(i) = Val(Mid$(FileToBeLoaded, IntD1, IntD2 - IntD1))
IntD1 = IntD2 + 1
IntD2 = InStr(IntD1, FileToBeLoaded, Chr$(13))
Virt(i) = Val(Mid$(FileToBeLoaded, IntD1, IntD2 - IntD1))
Next i
'MOVE PICGRAPH INTO PLACE
frmGraph.picGraph.Width = Currpos
frmGraph.picGraph.Left = frmGraph.Picture1.ScaleWidth - frmGraph.picGraph.Width
'DRAW IN OLD LINES
For i = 1 To Currpos
frmGraph.picGraph.Line (i - 1, 100 - MemLoad(i - 1))-(i, 100 - MemLoad(i)), RGB(255, 0, 0)
frmGraph.picGraph.Line (i - 1, 100 - Phys(i - 1))-(i, 100 - Phys(i)), RGB(0, 255, 0)
frmGraph.picGraph.Line (i - 1, 100 - Virt(i - 1))-(i, 100 - Virt(i)), RGB(0, 255, 255)
Next i
frmGraph.picGraph.Line (Currpos, 0)-(Currpos, 100), RGB(255, 255, 255) 'Draws a Grey Line where the new file has strarted
End Sub
Sub SAVE(Filename As String)
On Error GoTo Twat:
Dim filestring As String
'COMPOSE STRING TO SAVE
filestring = "Graph From " & Format$(Date) & " at " & Format$(Time) + Chr$(13)
filestring = filestring & " " & Chr$(13) 'When using the kind of load process seen in "sub_Load"
'this string is a kind of dummy line, it never returns as what you think
filestring = filestring & Currpos & Chr$(13) 'Denotes how many entries there will be into the File
For i = 0 To Currpos
filestring = filestring & MemLoad(i) & Chr$(13)
filestring = filestring & Phys(i) & Chr$(13)
filestring = filestring & Virt(i) & Chr$(13)
Next i
filestring = filestring & "Clone Software 1999 - Jack Hoxley" & Chr$(13)
Open Filename For Output As #6
Write #6, filestring
Close #6
frmGraph.lblopt(1).ForeColor = RGB(0, 255, 0)
MsgBox "Saved to '" & Filename & "' Succesfully", vbInformation, "Save"
Exit Sub
Twat:
MsgBox "Could not Save to '" & Filename & "'", vbInformation, "Save"
End Sub